package com.ouken.tool;


import com.ouken.com.R;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MydicAdapter extends BaseAdapter {
	Context context;  
    String[] contents; //formate is (OK,OK,word,##,word,##,word,##)
    
	public MydicAdapter(Context context,String[] contents) {
		this.context=context;  
        this.contents=contents;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return (contents.length - 2)/2;  
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return contents[position + 2];  
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;  
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if(convertView==null){  
            LayoutInflater inflater=LayoutInflater.from(context);  
            convertView=inflater.inflate(R.layout.mydic_item, null);  
        }  
        TextView t_word=(TextView)convertView.findViewById(R.id.adapter_mydic_tv_word);  
        t_word.setText(contents[2*position + 2]);  
        t_word.setTextColor(Color.BLACK);  
        t_word.setTextSize(20);  
        return convertView;  
	}

}
